package com.seadragon.app.ksr.model.tiger;


import static com.seadragon.app.ksr.model.KsrConstants.gf;

import org.apache.commons.lang.StringUtils;

import com.seadragon.app.ksr.model.Address;
import com.seadragon.app.ksr.model.AddressType;
import com.vividsolutions.jts.geom.Coordinate;

public class LocationFactory {

	public static Location getInstance(String name, AddressType type, String state, Double lat, Double lon){
		if (type!=null&&StringUtils.isNotEmpty(name)){
			switch (type) {
			case ROUTE:
				Address address = new Address();
				address.setAddressType(type);
				address.setCompleteAddress(name);
				address.setLocation(gf.createPoint(new Coordinate(lon, lat)));
				return address;
			case CITY:
				Place place = new Place();
				place.setName(name);
				place.setState(state);
				return place;
			case COUNTY:
				County county = new County();
				county.setState(state);
				county.setName(name);
				return county;
			case ZIP:
				Zip zip = new Zip();
				zip.setZip(name);
				return zip;
			case STATE:
				State st = new State();
				st.setName(name);
				return st;
			default:
				break;
			}
		}
		return null;
	}
}
